# Load packages

# General
library(tidyverse)
library(janitor)
library(here)
library(paletteer)

# Spatial
library(sf)
library(tmap)
# Read in data

land_use <- read_sf(dsn = here("Land_Use_Land_Cover_LULC"), layer = "Land_Use_Land_Cover_LULC")

watersheds <- read_sf(dsn = here("Watersheds"), layer = "Watersheds")

# st_crs(watersheds) checking CRS, both are EPSG: 4326
# Wrangle data for land cover

land_cover_oahu <- land_use %>%
  dplyr::select(landcover) %>%
  filter(landcover != 0) %>%  # Remove land use category of 0
  st_crop(xmin = -158.31, xmax = -157.62, ymin = 21.26, ymax = 21.75) # Crop to Oahu
# Create map for land use

oahu_map <- tm_basemap("Esri.WorldTopoMap")+
  tm_shape(land_cover_oahu) +
  tm_fill("landcover", title = "Land Cover", alpha = 0.5) +

tmap_mode("view")

oahu_map
# Wrangle data for watersheds

watersheds_oahu <- watersheds %>% 
  dplyr::select(wuname) %>% 
  st_crop(xmin = -158.31, xmax = -157.62, ymin = 21.26, ymax = 21.75) # Crop to Oahu
# Create map of watersheds


oahu_watersheds <- tm_basemap("Esri.WorldTopoMap") +
  tm_shape(watersheds_oahu) +
  tm_fill("wuname", title = "Watershed", alpha = 0.5)


tmap_mode("view")

oahu_watersheds